package de.koller.worlders.engine.tiles;

import de.koller.oceanFramework.OceanException;
import de.koller.oceanFramework.math.Vec;
import de.koller.worlders.WorldersRoot;
import de.koller.worlders.engine.entity.mo.MovingObject;

public class MOTile extends Tile {

	private MovingObject mo;
	
	public MOTile( ITile tileEntity ) {
		super( 0, 0, tileEntity );
	}

	public MOTile() {
		super( 0, 0 );
	}

	@Override
	public void generate( WorldersRoot root, Object... references ) {
		super.generate( root, references );

		if( references.length < 1 || references[0] instanceof MovingObject == false )
			throw new OceanException( "first argument must be the MovingObject!" );
		mo = (MovingObject)references[0];
		
		root.getEntityContainer().getMoTiles().add( this );
//		root.getEntityContainer().wphysics.addDynCol( this );
	}

	@Override
	public void ungenerate() {
		super.ungenerate();
		
		root.getEntityContainer().getMoTiles().remove( this );
//		root.getEntityContainer().wphysics.removeDynCol( this );
	}
	
	@Override
	public Vec getPosition() {
		return mo.getPosition();
	}

	@Override
	public Vec getSize() {
		return mo.getSize();
	}

	public MovingObject getMo() {
		return mo;
	}

}
